package com.njtoyo.taxi.admin.mapper.master.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;

import java.util.Arrays;
import java.util.Objects;

public enum CouponPlatform {
    mix(0, "mix"),
    app(1, "app"),
    wxmina(2, "小程序"),
    h5(3, "h5");

    @EnumValue
    private final int code;
    private final String desc;

    CouponPlatform(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public static CouponPlatform getByCode(Integer code) {
        if (Objects.isNull(code)) {
            return CouponPlatform.mix;
        }

        return Arrays.stream(CouponPlatform.values()).filter(e -> e.getCode() == code).findFirst().get();
    }
}
